test(filesystem): add MCP SDK regression coverage for directory_tree #3245
+60
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds regression test coverage only for a
directory_treestructured-content validation bug that appears to have already been fixed upstream.There are no runtime behavior changes in this PR.
Context
The
-32602error reported in:occurs when a tool declares
outputSchema: { content: string }but returnsstructuredContent.contentas an array.From git history, this appears to have been fixed in:
e6933ca— "Fix: Changed structuredContent output to match outputSchema (Fix: Changed structuredContent output to match outputSchema #3099)" (2025-12-11)Note: I opened this PR after seeing the open bug reports and reproducing the issue in an older build, but I did not initially confirm that
mainalready contained the fix. I’m keeping this PR scoped to test coverage in case it’s still useful as a regression guard.What this PR does
src/filesystem/__tests__/directory-tree.mcp-sdk.test.ts@modelcontextprotocol/sdk+StdioClientTransportto calldirectory_treeend-to-end.structuredContent.contentis astringand JSON-parseable.structured-content.test.tsslightly more robust on macOS by resolving the temp directory withfs.realpath()so the allowlist path matches/private/...temp paths.This is intended to help prevent reintroducing the same outputSchema/structuredContent mismatch.
Minimal reproduction snippet (for older builds)
I was able to reproduce the
-32602validation error by running the filesystem server over stdio and callingdirectory_treethrough the MCP SDK client.Maintainers can run the following snippet directly (Node 20+):
On buggy builds, this call throws
McpError: -32602 ... Expected string, received array at path: ["content"].Release context
I have not traced the exact release tag for
e6933ca, but based on timestamps it looks like the fix (2025-12-11) should be included in npm releases published after that date (for example@modelcontextprotocol/server-filesystem@2025.12.18and later).Happy to update this PR with the exact release tag if you'd like me to track it down precisely.
Test plan
npm test --workspace @modelcontextprotocol/server-filesystemFollow-up suggestion (optional)
If you'd like, I can follow up with a small CI-level "functional" test job that runs a tiny MCP SDK client against the built
dist/index.jsbinaries for select servers (filesystem, memory, etc.) to assert that schema validation passes for a few representative tool calls.I didn't include CI changes in this PR since I wasn't sure how you'd want to scope cross-package functional tests.
Authorship note
This contribution (bug identification, repro, test updates, and PR drafting) was authored with OpenAI Codex.